import request from '@/utils/request'
import qs from 'qs'

export function login(username, password, code) {
  const data = {
    username,
    password,
    code
  }
  return request({
    url: '/common/login',
    method: 'post',
    data: qs.stringify(data)
  })
}

export function getCode() {
  return request({
    url: `/common/authCode?=${+new Date()}`,
    method: 'get',
    responseType: 'arraybuffer'
  })
}

// export function getInfo(token) {
//   return request({
//     url: '/user/info',
//     method: 'get',
//     params: { token }
//   })
// }

// export function logout() {
//   return request({
//     url: '/user/logout',
//     method: 'post'
//   })
// }

export function changePassword(oldpass, password) {
  const data = {
    password,
    oldpass
  }
  return request({
    url: '/common/updatePass',
    method: 'post',
    data: qs.stringify(data)
  })
}
// 密码找回接口
export function retrievePassword(phone, code) {
  const data = {
    phone,
    code
  }
  return request({
    url: '/common/retrievePassword',
    method: 'post',
    data: qs.stringify(data)
  })
}
// 短信验证码
export function getMsgCode(phone) {
  const data = {
    phone
  }
  return request({
    url: '/common/wechat/sendMsg',
    method: 'post',
    data: qs.stringify(data)
  })
}
